import { request } from '@/utils/request';
import { stringify } from 'qs';


// POST 下單
export async function queryOrderCreate(data: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/order`, {
    method: 'POST',
    data
  });
}

// 訂單详情
export async function queryOrderDetail({ id, isReturnUmeIntegral }: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/order/${id}?isReturnUmeIntegral=${isReturnUmeIntegral}`,)
}


// 查询支付列表
export async function queryPayWay(data: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/order/payway?${stringify(data)}`,)
}


// 查詢支付信息
export async function queryPayInfo({ lineOrderId, payWay }: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/order/lineresult?lineOrderId=${lineOrderId}&payWay=${payWay}`)
}

//支付
export async function queryOrderPay(data: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/order/payByConsumer`, {
    method: 'POST',
    data
  })
}

//提交發票信息
export async function queryInvoice(data: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/invoice`, {
    method: 'POST',
    data
  });
}

//愛心碼
export async function queryLoveCode(): Promise<responseData> {
  return request(`/scan/qrcode/meal/invoice/lovecode`)
}

// 消费者查询订单是否接单
export async function queryReceiveOrderStatus(orderId: string): Promise<responseData> {
  return request(`/scan/qrcode/meal/order/receiveOrderStatus?orderId=${orderId}`)
}

// 呼叫服務
export async function queryServeCall(data: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/serve/call`, {
    method: 'POST',
    data
  })
}

// 獲取全部的訂單列表
export async function queryAllOrderList(data: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/api/order/consumer/list?${stringify(data)}`)
}


// 待评价的列表
export async function queryWaitEvaluateOrderList(data: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/api/order/wait/evaluate/list/web?${stringify(data)}`)
}


// 支付結果
export async function queryPayResult(lineOrderId: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/order/lineresult?lineOrderId=${lineOrderId}`)
}

// 模擬請求支付結果
export async function queryTestPayResult(lineOrderId: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/order/lineresult/test?lineOrderId=${lineOrderId}`)
}

// 0元訂單標記成功
export async function queryOrderFinish(data: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/order/finish`, {
    method: 'PUT',
    data
  })
}

//評論
export async function queryComment(data: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/comment/save`, {
    method: 'POST',
    data
  })
}

// 评论详情
export async function queryCommentDetail(data: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/comment/detail?orderId=${data.orderId}`, {
    method: 'POST',
    data
  })
}

// 套餐詳情
export async function queryPackage(productId: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/package/${productId}`)
}

// 調接口計算價格
export async function queryCalculate(data: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/order/calculate/amount`, {
    method: 'POST',
    data
  })
}

// 使用積分抵扣
export async function queryUseIntegral(data: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/order/update/integral`, {
    method: 'PUT',
    data
  })
}

// 消费者扫描是否进入订单详情
export async function queryMyLastOrder(data: any): Promise<responseData> {
  return request(`/scan/qrcode/meal/order/mylastorder?${stringify(data)}`)
}

